<?php

class dropTable
{
    var $dbName;
    function structure()
    {
        global $con, $HTTP_POST_VARS;
        $out="";
        $res=mysql_list_tables($this->dbName);
        $nt=mysql_num_rows($res);
        for ($a=0;$a<$nt;$a++)
        {
            $row=mysql_fetch_row($res);
            $tablename=$row[0];
			if(($tablename=="TblArchive_Lowest_00") || ($tablename=="TblArchive_Lowest_01") || ($tablename=="TblArchive_Lowest_02") || ($tablename=="TblArchive_Lowest_03") || ($tablename=="TblArchive_Lowest_PC_03") || ($tablename=="TblArchive_Today_02") || ($tablename=="TblArchive_Today_03") || ($tablename=="TblArchive_Today_PC_03"))
			{
				continue;
			}
					$out .= "\nDROP TABLE IF EXISTS `". $tablename."`; \n\n";
					$res2=mysql_query('SHOW CREATE TABLE ' . $this->dbName . '.' . $tablename);
					$tmpres        = mysql_fetch_array($res2);
					if(isset($HTTP_POST_VARS['tables']) && $HTTP_POST_VARS['tables'] == "on")
					{
						$out .= $tmpres[1];
						$out .= "\n\n";
					}
					if(isset($HTTP_POST_VARS['data']) && $HTTP_POST_VARS['data'] == "on")
					{
						$res2=mysql_query("select * from `$tablename`");
						$nf=mysql_num_fields($res2);
						$nr=mysql_num_rows($res2);
						for ($c=0;$c<$nr;$c++){
							$out .= "insert into `$tablename` values (";
							$row=mysql_fetch_row($res2);
							for ($d=0;$d<$nf;$d++)
							{
								$data=strval($row[$d]);
								$out .="'".mysql_escape_string($data)."'";
								if ($d<($nf-1))
								{
									$out .=", ";
								}
							}
						$out .=");\n";
						}
			    }
        }
    $out .= "";
    return $out;
    }
}

?>
